Split a string on the last K occurrence of the delimiter¶
S.rsplit(‘,’, 5)
Split a string on the last occurrence of the delimiter.
S = "w,3,r,e,s,o,u,r,c,e"
print(S.rsplit(',', 1)) # ['w,3,r,e,s,o,u,r,c', 'e']
print(S.rsplit(',', 2)) # ['w,3,r,e,s,o,u,r', 'c', 'e']
print(S.rsplit(',', 5)) # ['w,3,r,e,s', 'o', 'u', 'r', 'c', 'e']